package cn.edu.nju.oraldefense.action;

import javax.annotation.Resource;

import org.apache.struts2.json.annotations.JSON;

import cn.edu.nju.oraldefense.model.Graduate;
import cn.edu.nju.oraldefense.service.GraduateService;

import com.opensymphony.xwork2.ActionSupport;

public class GraduateAddAction extends ActionSupport {

	private Graduate graduate;
	private GraduateService graduateService;
	private boolean success;

	@JSON(serialize = false)
	public Graduate getGraduate() {
		return graduate;
	}

	public void setGraduate(Graduate graduate) {
		this.graduate = graduate;
	}

	@JSON(serialize = false)
	public GraduateService getGraduateService() {
		return graduateService;
	}

	@Resource
	public void setGraduateService(GraduateService graduateService) {
		this.graduateService = graduateService;
	}

	public boolean isSuccess() {
		return success;
	}

	public void setSuccess(boolean success) {
		this.success = success;
	}

	public String execute() {
		if (graduate != null) {
			graduate.setPassword("123456");
			graduateService.addGraduate(graduate);
			success = true;
		}
		return SUCCESS;
	}

}
